<extend name="Layout:form"/>
<block name="title"><title>字段修改</title></block>
<block name="subnav">
    <h2 class="title-1 line-x f14 fb blue lh28">模型管理--<?php echo $model['name']; ?>字段管理</h2>
    <a href="javascript:;" class="on"><em>修改字段</em></a><span>|</span><a href="__CONTROLLER__/index?modelid=<?php echo $modelid; ?>"><em>管理模型字段</em></a>
</block>
<block name="main">
    <form name="myform" id="myform" action="__CONTROLLER__/edit" method="post">
        <div class="common-form">
            <table width="100%" class="table_form">
                <tr>
                    <th><strong>字段类型</strong><br /></th>
                    <td>
                        <input type="hidden" name="info[formtype]" value="<?php echo $model_field['formtype'];?>">
                        <?php echo \Org\Util\Form::select($fields,$model_field['formtype'],'name="info[formtype]" id="formtype" onchange="javascript:field_setting(this.value);" disabled', '请选择字段类型');?>
                    </td>
                </tr>
                <tr>
                    <th><strong>作为主表字段</strong></th>
                    <td>
                        <input type="hidden" name="info[issystem]" id="issystem" value="<?php echo $model_field['issystem'] ? 1 : 0;?>">
                        <input type="radio" name="issystem" id="field_basic_table1" value="1" <?php if($model_field['issystem']) echo 'checked';?> disabled> 是 <input type="radio" id="field_basic_table0" name="issystem" value="0" <?php if(!$model_field['issystem']) echo 'checked';?> disabled> 否
                    </td>
                </tr>
                <tr>
                    <th width="25%"><font color="red">*</font> <strong>字段名</strong><br />
                        只能由英文字母、数字和下划线组成，并且仅能字母开头，不以下划线结尾
                    </th>
                    <td><input type="text" name="info[field]" id="field" size="20" class="input-text" value="<?php echo $model_field['field']; ?>" <?php if(in_array($model_field['field'],$forbid_delete)) echo 'readonly';?>></td>
                </tr>
                <tr>
                    <th><font color="red">*</font> <strong>字段别名</strong><br />例如：文章标题</th>
                    <td><input type="text" name="info[name]" id="name" size="30" class="input-text" value="<?php echo $model_field['name']?>"></td>
                </tr>
                <tr>
                    <th><strong>字段提示</strong><br />显示在字段别名下方作为表单输入提示</th>
                    <td><textarea name="info[tips]" rows="2" cols="20" id="tips" style="height:40px; width:80%"><?php echo htmlspecialchars($model_field['tips']);?></textarea></td>
                </tr>

                <tr>
                    <th><strong>相关参数</strong><br />设置表单相关属性</th>
                    <td><?php echo $form_data;?></td>
                </tr>
                <?php if(in_array($model_field['formtype'],$att_css_js)) { ?>
                <tr>
                    <th><strong>表单附加属性</strong><br />可以通过此处加入javascript事件</th>
                    <td><input type="text" name="info[formattribute]" size="50" class="input-text" value="<?php echo htmlspecialchars($model_field['formattribute']);?>"></td>
                </tr>
                <tr>
                    <th><strong>表单样式名</strong><br />定义表单的CSS样式名</th>
                    <td><input type="text" name="info[css]" size="10" class="input-text" value="<?php echo htmlspecialchars($model_field['css']);?>"></td>
                </tr>
                <?php } ?>
                <tr>
                    <th><strong>字符长度取值范围</strong><br />系统将在表单提交时检测数据长度范围是否符合要求，如果不想限制长度请留空</th>
                    <td>最小值：<input type="text" name="info[minlength]" id="field_minlength" value="<?php echo $model_field['minlength'];?>" size="5" class="input-text">最大值：<input type="text" name="info[maxlength]" id="field_maxlength" value="<?php echo $model_field['maxlength'];?>" size="5" class="input-text"></td>
                </tr>
                <tr>
                    <th><strong>数据校验正则</strong><br />系统将通过此正则校验表单提交的数据合法性，如果不想校验数据请留空</th>
                    <td><input type="text" name="info[pattern]" id="pattern" value="<?php echo $model_field['pattern'];?>" size="40" class="input-text">
                        <select name="pattern_select" onchange="javascript:$('#pattern').val(this.value)">
                            <option value="">常用正则</option>
                            <option value="/^[0-9.-]+$/">数字</option>
                            <option value="/^[0-9-]+$/">整数</option>
                            <option value="/^[a-z]+$/i">字母</option>
                            <option value="/^[0-9a-z]+$/i">数字+字母</option>
                            <option value="/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/">E-mail</option>
                            <option value="/^[0-9]{5,20}$/">QQ</option>
                            <option value="/^http:\/\//">超级链接</option>
                            <option value="/^(1)[0-9]{10}$/">手机号码</option>
                            <option value="/^[0-9-]{6,13}$/">电话号码</option>
                            <option value="/^[0-9]{6}$/">邮政编码</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th><strong>数据校验未通过的提示信息</strong></th>
                    <td><input type="text" name="info[errortips]" value="<?php echo htmlspecialchars($model_field['errortips']);?>" size="50" class="input-text"></td>
                </tr>
                <tr>
                    <th><strong>显示在列表页</strong></th>
                    <td><input type="radio" name="info[islist]" value="1" <?php if($model_field['islist']) echo 'checked';?>> 是 <input type="radio" name="info[islist]" value="0" <?php if(!$model_field['islist']) echo 'checked';?>> 否</td>
                </tr>
                <tr>
                    <th><strong>值唯一</strong></th>
                    <td><input type="radio" name="info[isunique]" value="1" id="field_allow_isunique1" <?php if($model_field['isunique']) echo 'checked';?>> 是 <input type="radio" name="info[isunique]" value="0" id="field_allow_isunique0" <?php if(!$model_field['isunique']) echo 'checked';?>> 否</td>
                </tr>
                <tr>
                    <th><strong>预留字段</strong><br />不会被显示在添加页面</th>
                    <td><input type="radio" name="info[iscore]" value="1"  <?php if($model_field['iscore']) echo 'checked';?>> 是 <input type="radio" name="info[iscore]" value="0" <?php if(!$model_field['iscore']) echo 'checked';?>> 否 </td>
                </tr>
                <tr>
                    <th><strong>作为搜索条件</strong></th>
                    <td><input type="radio" name="info[issearch]" value="1" id="field_allow_search1" <?php if($model_field['issearch']) echo 'checked';?>> 是 <input type="radio" name="info[issearch]" value="0" id="field_allow_search0" <?php if(!$model_field['issearch']) echo 'checked';?>> 否</td>
                </tr>
                <tr>
                    <th><strong>在推荐位中显示</strong></th>
                    <td><input type="radio" name="info[isadd]" value="1"  <?php if($model_field['isadd']) echo 'checked';?>/> 是 <input type="radio" name="info[isadd]" value="0" <?php if(!$model_field['isadd']) echo 'checked';?>/> 否</td>
                </tr>
            </table>
            <div class="bk15"></div>
            <input name="info[modelid]" type="hidden" value="<?php echo $modelid; ?>">
            <input name="fieldid" type="hidden" value="<?php echo $fieldid; ?>">
            <input name="oldfield" type="hidden" value="<?php echo $model_field['field']; ?>">
            <div class="btn"><input name="dosubmit" type="submit" value="提交" class="button"></div>
        </div>
    </form>
</block>
<block name="footer">
    <script type="text/javascript">
        $(function() {
            $.formValidator.initConfig({autotip:true,formid:"myform"});
            $("#field").formValidator({onshow:"请输入字段名",onfocus:"字段名长度必须为1-20位"}).regexValidator({regexp:"^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,19}[^_]$",onerror:"字段名称不正确"}).inputValidator({min:1,max:20,onerror:"字段名长度必须为1-20位"}).ajaxValidator({
                type : "get",
                url : "__CONTROLLER__/public_checkfield",
                data : "modelid=<?php echo $modelid?>&oldfield=<?php echo $model_field['field'];?>",
                datatype : "html",
                cached:false,
                getdata:{issystem:'issystem'},
                async:'false',
                success : function(data){
                    if( data == "1" ){
                        return true;
                    } else {
                        return false;
                    }
                },
                buttons: $("#dosubmit"),
                onerror : "字段名已经存在",
                onwait : "请稍候..."
            }).defaultPassed();
            $("#formtype").formValidator({onshow:"请选择字段类型",onfocus:"请选择字段类型",oncorrect:"输入正确",defaultvalue:""}).inputValidator({min:1,onerror: "请选择字段类型"}).defaultPassed();
            $("#name").formValidator({onshow:"请输入别名",onfocus:"字段别名不能为空",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入别名"}).defaultPassed();
        });
    </script>
</block>